package org.csu.mypetstore_seller.controller;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
import org.apache.coyote.http11.HttpOutputBuffer;
import org.csu.mypetstore_seller.domain.Account;
import org.csu.mypetstore_seller.service.AccountService;
import org.csu.mypetstore_seller.service.OrderService;
import org.csu.mypetstore_seller.service.OrderStatusService;
import org.csu.mypetstore_seller.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.HttpRequestHandler;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/main")
public class MainController {
    @Autowired
    OrderService orderService;
    @Autowired
    AccountService accountService;
    @Autowired
    ProductService productService;
    @Autowired
    OrderStatusService orderStatusService;

    @GetMapping("/main")
    public String main(Model model){
        model.addAttribute("orderNum", orderService.getNum()); //总订单数
        model.addAttribute("pOrderNum", orderStatusService.getNum()); //代发货订单数
        System.out.println(orderStatusService.getNum());
        model.addAttribute("accountNum", accountService.getNum()); //总用户数
        model.addAttribute("normalAccountNum", accountService.getNum1());//正常用户数
        model.addAttribute("productNum", productService.getNum());//总商品数
        model.addAttribute("PProductNum", productService.getNum1());//缺货商品数
        return "main/main";
    }
}
